<template>
	<view class="AI-chat" style="height:calc(100vh - 64px)">
		<common-navbar title="小律懂法智能机器人" :titleSize="24"></common-navbar>
		<chat @queryCallback="getQueryCallback" @openWebview="openWebview" @openMiniProgram="openMiniProgram"
			generic:queryMessage="queryMessage" @onLinkpress="onLinkpress"/>
	</view>
</template>

<script>
	import queryMessage from "./components/query-message/queryMessage.vue";
	export default {
		data() {
			return {

			}
		},
		components:{
			queryMessage
		},
		async onLoad() {
			await this.$loginStatus;
			this.AIChatInit();
		},
		methods: {
			AIChatInit() {
				const plugin = requirePlugin("chatbot");
				plugin.init({
					appid: "WcIeKt0rg68tgEnk5NUqz4qPJPnOBQ",
					success: () => {
						this.$showToast('初始化成功')
					},
					fail: error => {
						this.$showToast('初始化失败')
					},
					guideList: ["法律援助"],
					openid: this.userInfo.openid,
					textToSpeech: 1,
					welcome: ["请问有什么需要帮助？"],
					// welcomeImage: 'http://inews.gtimg.com/newsapp_bt/0/10701537095/1000',
					background: "rgba(247,251,252,1)",
					guideCardHeight: 40,
					operateCardHeight: 90,
					history: false,
					navHeight: 0,
					robotHeader: 'https://res.wx.qq.com/mmspraiweb_node/dist/static/miniprogrampageImages/talk/leftHeader.png',
					userHeader: this.userInfo.avatars,
					userName: '大闹腾',
					anonymous: false,
					// 是否隐藏服务评价按钮
					hideMovableButton: false,
					// 是否隐藏消息点赞按钮
					hideTheLikeButton: false,
					operateCardMode: 1,
					inputPlaceHolder: "请输入",
					noWaiterInfo: false,
				});
			},
			getQueryCallback() {
				console.log('getQueryCallback')
			},
			openWebview(e) {
				console.log('openWebview>>>>>>>>>>>>>',e);
				const page = e.target.weburl.split('?')[1];
				this.$u.route(page)
			},
			openMiniProgram() {

			},
			onLinkpress(e){
				console.log('linkpress>>>>>>>>>>>>>>>>>>',linkpress);
			}
		}
	}
</script>

<style scoped lang="scss">
	@import "./AIChat.scss";
</style>
